package com.easyaop.test.core.junit.super_test;

import com.easyaop.core.listener.DebugAgentListener;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;

import static com.easyaop.test.core.junit.JunitTest.testMethodAround;

public class JunitTestSuper2pkg {
    static {
        final String ROOT_PATH = "12";

        String dirs = "dump_class";
        String path = ROOT_PATH + File.separator + dirs;
        System.setProperty(DebugAgentListener.DEBUG_LOCATION_PROPERTY, path);
    }

    @TestFactory
    Collection<DynamicTest> tests() {
        return Arrays.stream(ChildBean.class.getDeclaredMethods())
                .filter(method -> method.getName().startsWith("test_"))
                .map(method -> DynamicTest.dynamicTest(method.getName(), () -> testMethodAround(method)))
                .collect(Collectors.toSet());
    }
}
